/**
 * Created by lijtg on 2015/10/21.
 */
$(document).ready(function () {
    var main = {
        config: {
        },
        cache: {
            timer: null,
            PROGECT_ID: ''
        },
        getAcctInfo: function (){
            $.ajax({
                type: "GET",
                url: common.hostPath + "/api/accountQuery",
                data: {
                    IDENTIFICATION_TYPE: '101',
                    IDENTIFICATION_NUMBER: '',
                    CUSTOMER_NAME: '',
                    BASE_ACCT_NO: ''
                },
                dataType : 'json',
                success: function (data) {
                    if (data.errCode == "000000") {

                    }
                    else {
                        common.responseFail(data)
                    }
                },
                complete: function(){

                },
                error: common.responseError
            });
        },
        getBindAcctInfo: function (){
            $.ajax({
                type: "GET",
                url: common.hostPath + "/api/bindAccountQuery",
                data: {
                    IDENTIFICATION_TYPE: '101',
                    IDENTIFICATION_NUMBER: '',
                    CUSTOMER_NAME: '',
                    BASE_ACCT_NO: ''
                },
                dataType : 'json',
                success: function (data) {
                    if (data.errCode == "000000") {

                    }
                    else {
                        common.responseFail(data)
                    }
                },
                complete: function(){

                },
                error: common.responseError
            });
        },
        getTranDetail: function (){
            if(!main.formCheck()) return;
            $.ajax({
                type: "GET",
                url: common.hostPath + "/api/tranDetail",
                data: {
                    PROGECT_ID: main.cache.PROGECT_ID
                },
                dataType : 'json',
                success: function (data) {
                    if (data.errCode == "000000") {
                        $('#detail-table').DataTable(main.tableSettings({
                            data: [
                                {DATE: '2017-09-09',TRAN_TYPE: '退款',AMOUNT: '1245.00',BALANCE: '40000.00',DESC: '快捷支付充值'},
                                {DATE: '2017-09-09',TRAN_TYPE: '退款',AMOUNT: '1245.00',BALANCE: '40000.00',DESC: '快捷支付充值'},
                             ]
                        }));
                        //layer.open({
                        //    content: '提交成功',
                        //    btn: '确定'
                        //});
                    }
                    else {
                        common.responseFail(data)
                    }
                },
                complete: function(){
                },
                error: common.responseError
            });
        },
        formCheck: function () {
            return true;
        },
        regHammer: function () {

        },
        tableSettings: function (reSettings){
            var settings = {
                select: true,
                scrollX: true,
                processing: true,
                autoWidth: true,
                pagingType: "full_numbers",
                paging: true,
                lengthChange: false,
                data: [
                    {DATE: '2017-09-09',TRAN_TYPE: '退款',AMOUNT: '1245.00',BALANCE: '40000.00',DESC: '快捷支付充值'},
                    {DATE: '2017-09-09',TRAN_TYPE: '退款',AMOUNT: '1245.00',BALANCE: '40000.00',DESC: '快捷支付充值'},
                    {DATE: '2017-09-09',TRAN_TYPE: '退款',AMOUNT: '1245.00',BALANCE: '40000.00',DESC: '快捷支付充值'},
                    {DATE: '2017-09-09',TRAN_TYPE: '退款',AMOUNT: '1245.00',BALANCE: '40000.00',DESC: '快捷支付充值'},
                    {DATE: '2017-09-09',TRAN_TYPE: '退款',AMOUNT: '1245.00',BALANCE: '40000.00',DESC: '快捷支付充值'},
                    {DATE: '2017-09-09',TRAN_TYPE: '退款',AMOUNT: '1245.00',BALANCE: '40000.00',DESC: '快捷支付充值'},
                    {DATE: '2017-09-09',TRAN_TYPE: '退款',AMOUNT: '1245.00',BALANCE: '40000.00',DESC: '快捷支付充值'}
                ],
                columns: [
                    { "data": "DATE"},
                    { "data": "TRAN_TYPE"},
                    { "data": "AMOUNT"},
                    { "data": "BALANCE"},
                    { "data": "DESC"}
                ]
            };
            if(reSettings){
                for (var k in reSettings) {
                    settings[k] = reSettings[k];
                }
            }
            return settings;
        },
        init: function () {
            //获取三方平台传来的参数
            main.cache.PROGECT_ID = common.getUrlParams().PROGECT_ID;

            main.regHammer();
            main.getAcctInfo();
            main.getBindAcctInfo();
            main.getTranDetail();
            $('#detail-table').DataTable(main.tableSettings());
        }
    };

    main.init();
});
